using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using PuzzleDulex.bamboo;

namespace PuzzleDeluxe.bamboo
{
    public class MyTimer
    {
        public double timePass;
        public bool start = false;

        public void updateCount(GameTime gameTime)
        {
            if (start)
            {
                timePass += gameTime.ElapsedGameTime.TotalMilliseconds;
            }

        }

        public MyTimer(long time)
        {
            timePass = (double)time;
        }

        public MyTimer()
        {
            // TODO: Complete member initialization
        }

        public void pauseTimer()
        {
            start = false;
        }

        public void resetTimer()
        {
            start = false;
            timePass = 0;
        }

        public string toString()
        {
            string timeString = " ";
            int Hours = (int)(timePass / (1000 * 60 * 60));
            int Minutes = (int)((timePass % (1000 * 60 * 60)) / (1000 * 60));
            int Seconds = (int)(((timePass % (1000 * 60 * 60)) % (1000 * 60)) / 1000);

            string hourString = Hours < 10 ? ("0" + Hours.ToString()) : Hours.ToString();
            string minuteString = Minutes < 10 ? ("0" + Minutes.ToString()) : Minutes.ToString();
            string secondString = Seconds < 10 ? ("0" + Seconds.ToString()) : Seconds.ToString();

            timeString += hourString;
            timeString += ":" + minuteString;
            timeString += ":" + secondString;

            return timeString;
        }

        public int elapsedTimeInSecond()
        {
            int Seconds = (int)(timePass/1000);
            return Seconds;
        }


        public void drawTime(SpriteBatch g, int x, int y)
        {
            TextUtil.printString(g, x + 10, y - 50, "Time elapsed", Font.SIZE_SMALL, Color.Blue);
            TextUtil.printString(g, x - 20, y,  this.toString(), Font.SIZE_LARGE, Color.Red);
        }
    }
}
